    <div class="datagridcontainer" id="dgc<?=$frmtime?>">
        <table width="100%">
			<tr  class="h0">
				<td>No.</td>
                <?
                    $col_count = 2; 
                    //print_object($dgcolumns);exit;
                    foreach($dgcolumns as $key => $column) {
                    if($column['visible']) {
                        $widthstr = '';
                        if(isset($column['width'])) {
                            $width = $column['width'];
                            $widthstr = " width=\"".$width."\"";
                        }
                        echo "<td".$widthstr.">".$column['label']."</td>";
                        $col_count++;    
                    }
                    
                } 
                if(isset($report) && $report == true) {
                    $col_count--;
                } else {
                ?>
				<td width="80">Actions</td>
                <?}?>
			</tr>
            <?
            if(isset($dgfilter) && $dgfilter == true) {
            ?>
            <tr>
                <td></td>
            <?
                foreach($dgcolumns as $key => $column) {
                    if($column['visible']) {
                        if(isset($column['filter']) && $column['filter'] == true) {
            ?>
                        <td><input type="text" class="textfilter" value="" id="" /></td>
            <?                        
                        } else {
            ?>
                        <td></td>
            <?            
                        }    
                    }
                }
            ?>
                <td>
                    <div class="gbutton">
                        <div class="filter">&nbsp;</div>
                    </div>
                </td>
            </tr>
            <?    
            }
            ?>
            <?
                $i = ($current_page-1)*$rows_per_page + 1; 
                $total_cols = array();
                foreach($dgitems as $dgitem) {
            ?>
            <tr class="d<?=$i%2?>">
                <td style="padding-left: 5px;"><?=$i?></td>
            <?
                foreach($dgcolumns as $key => $column) {
                    if(isset($column['sum']) && $column['sum'] == true) {
                        if(!isset($total_cols[$key])) {
                            $total_cols[$key] = 0;
                        }
                        $total_cols[$key] += $dgitem[$key];
                    }
                    if($column['visible']) {
                        $colvalue = $dgitem[$key];
                        switch($column['type']) {
                            case 'boolean':
                                    $colvalue = ($colvalue == true) ? 'Yes' : 'No';
                                    break;
                            case 'textarea':
                                    $colvalue = "<textarea style='resize:none' rows='2' cols='30' readonly='true'>".$colvalue."</textarea>";
                                    break;
                            case 'link':
                                    $link_id = isset($column['key']) ? $dgitem[$column['key']] : $dgitem[$pk];
                                    if($link_id!=0) {
                                        $colvalue = "<a class=\"gdlink\" itemname=\"$dgitem[$itemname]\" href=\"".base_url($column['href']."/".$link_id)."\">".$colvalue."</a>";
                                    }                                    
                                    break;
                            case 'date':
                                    $colvalue = ($colvalue!="0000-00-00") ? date("d-m-Y",strtotime( $colvalue )) : "";
                                    break;
                            case 'enum':
                                    $colvalue =  $column['enum'][$colvalue];
                                    break; 
                            case 'format':
                                    $function = $column['function'];
                                    $params = isset($column['param']) ? $column['param'] : $key;
                                    $colvalue =  format_grid_val($function,$params,$dgitem);
                                    break;  
                        }
                        echo "<td>".$colvalue."</td>";
                    }
                }
                if(isset($report) && $report == true) {
                    
                } else {
            ?>
                <td>
				    <div class="gbutton">
                        <? if(isset($actions['view'])) {?>
                        <div class="view" itemname="<?=$dgitem[$itemname]?>" itemid="<?=$dgitem[$pk]?>">&nbsp;</div>
                        <? } 
                           if(isset($actions['edit'])) { 
                        ?>
                        <div class="edit" itemname="<?=$dgitem[$itemname]?>" itemid="<?=$dgitem[$pk]?>">&nbsp;</div>
                        <? } 
                           if(isset($actions['delete'])) { 
                        ?>
                        <div class="delete" itemname="<?=$dgitem[$itemname]?>" itemid="<?=$dgitem[$pk]?>">&nbsp;</div>
                        <? } 
                        ?>
                    </div>
				</td>
            </tr>
            <?
                }
                    $i++;      
            }
            if(isset($report) && $report == true) {
            ?>
            <tr  class="h0">
				<td colspan="<?=$total_span?>">Total</td>
                <?
                    
                    //print_object($dgcolumns);exit;
                    $i=1;
                foreach($dgcolumns as $key => $column) {
                    $sum_value = "";
                    if($column['sum']) {
                        if($total_cols[$key]){
                            $sum_value = $total_cols[$key];
                        }                    
                    }
                    if($i>=$total_span) {
                        echo "<td>".$sum_value."</td>";
                    }
                    $i++;
                }
                ?>
			</tr>
            <?       
                } else {            
            ?>
			<tr class="f0">
				<td colspan="<?=$col_count?>">
                    <div style="float:left; min-height: 16px;">
                        Showing <?=count($dgitems)?> of <?=$total?>
                    </div>
                    <div style="float:right; min-height: 16px;">
                    <?
                        if($pages_total>1) {
                    ?>
                    
				        Page:<select name="page" id="pageselect">
                    <?
                        for($i=1;$i<=$pages_total;$i++) {
                    ?>
                            <option <? if(isset($current_page) && $current_page == $i) echo "selected"; ?> value="<?=$i?>"><?=$i?></option>
                    <?                            
                        }
                    ?>
							</select>
                    
                    <?
                        }
                    ?>
					</div>
				</td>
			</tr>
            <?}?>
		</table>
        <div id="modal<?=$frmtime?>" style="display: none; position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; background: rgba(245, 242, 234, 0.5);">
            <div style="width: 250px; margin: 150px auto;"><strong>Processing</strong><br/><img src="/images/ajaxloader.gif" /></div>
        </div>
        <div style="display: none;">
            <form id="frmEdit<?=$frmtime?>" method="POST" action="<?=base_url($actions['edit'])?>">
                <input type="hidden" id="edit_<?=$pk?>" name="<?=$pk?>" value="" />
            </form>
            <form id="frmDelete<?=$frmtime?>" method="POST" action="<?=base_url($actions['delete'])?>">
                <input type="hidden" id="delete_<?=$pk?>" name="<?=$pk?>" value="" />
            </form>
            <form id="frmPageChange<?=$frmtime?>" method="POST" action="">
                <input type="hidden" id="hidpage" name="page" value="" />
            </form>
        </div>
        <script language="javascript" type="text/javascript">
            $(document).ready( function() {
                $("#dgc<?=$frmtime?> td > .gbutton > div.view").click(function() {
                    var __viewurl = "<?=base_url($actions['view'])?>"+"/"+$(this).attr('itemid');
                    addMyWin( $(this).attr('itemname'), __viewurl );
                });
                $("#dgc<?=$frmtime?> td > .gbutton > div.edit").click(function() {
                    var __viewurl = "<?=base_url($actions['view'])?>"+"/"+$(this).attr('itemid');
                    addMyWin( $(this).attr('itemname'), __viewurl );
                });
                $("#dgc<?=$frmtime?> td > .gbutton > div.delete").click(function() {
                    var itemname = $(this).attr('itemname');
                    var answer = confirm ("Are sure want to delete "+itemname+" ?");
                    var $tr = $(this).closest("tr");
                    if(answer) {
                        //location.href = '?action=delcomp&id='+varCatId;
                        $("#modal<?=$frmtime?>").show(); 
                   	    var jqxhr = jQuery.getJSON(
                            "<?=$actions['delete']?>"+"?json=1",
                            "id="+($(this).attr('itemid')), 
                            function (data) {
                               $("#modal<?=$frmtime?>").hide();
                               if(data.status == 1) {
                                    $tr.remove();
                               } else {
                                alert(data.error);
                               }
                               
                            }
                        );
                    }
                });
                $(".datagridcontainer tr td a.gdlink").click(function(event) {
                    event.preventDefault();
                    var __viewurl = $(this).attr("href");
                    var __title = $(this).attr('itemname');
                    addMyWin( $(this).attr('itemname'), __viewurl );
                });
                $("#dgc<?=$frmtime?> #pageselect").change(function() {
                    //$("#dgc<?=$frmtime?> #hidpage").val($(this).val());
                    //alert($(this).val());
                    //$("#dgc<?=$frmtime?> #frmPageChange").submit();
                    var cui = $('#contenttabs .ui-tabs-panel:visible'); 
               	    var jqxhr = $.post(
                        "<?=$actions['page']?>", 
                        $("#frmFilter<?=$frmtime?>").serialize()+"&page="+$(this).val(), 
                        function (data) {
                            $(cui).html(data);
                        }
                    );
                    $(cui).html('<div id="loadingdiv"><div class="centerdiv"><strong>Processing</strong><br/><img src="/images/ajaxloader.gif" /></div></div>');
                });
            });
        </script>
    </div>